﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using H2.Streams;
using System.Reflection;

namespace Mystery
{
    public class AIDifficulty
    {
        public float EasyEnemyDamage;
        public float NormalEnemyDamage;
        public float HeroicEnemyDamage;
        public float LegendaryEnemyDamage;

        public float EasyEnemyVitality;
        public float NormalEnemyVitality;
        public float HeroicEnemyVitality;
        public float LegendaryEnemyVitality;

        public float EasyEnemySheild;
        public float NormalEnemySheild;
        public float HeroicEnemySheild;
        public float LegendaryEnemySheild;

        public float EasyEnemyRecharge;
        public float NormalEnemyRecharge;
        public float HeroicEnemyRecharge;
        public float LegendaryEnemyRecharge;

        public float EasyFriendDamage;
        public float NormalFriendDamage;
        public float HeroicFriendDamage;
        public float LegendaryFriendDamage;

        public float EasyFriendVitality;
        public float NormalFriendVitality;
        public float HeroicFriendVitality;
        public float LegendaryFriendVitality;

        public float EasyFriendSheild;
        public float NormalFriendSheild;
        public float HeroicFriendSheild;
        public float LegendaryFriendSheild;

        public float EasyFriendRecharge;
        public float NormalFriendRecharge;
        public float HeroicFriendRecharge;
        public float LegendaryFriendRecharge;

        public float EasyInfectionForms;
        public float NormalInfectionForms;
        public float HeroicInfectionForms;
        public float LegendaryInfectionForms;

        byte[] Padding = new byte[16];
        public float EasyRateOfFire;
        public float NormalRateOfFire;
        public float HeroicRateOfFire;
        public float LegendaryRateOfFire;

        public float EasyProjectileError;
        public float NormalProjectileError;
        public float HeroicProjectileError;
        public float LegendaryProjectileError;

        public float EasyBurstError;
        public float NormalBurstError;
        public float HeroicBurstError;
        public float LegendaryBurstError;

        public float EasyNewTargetDelay;
        public float NormalNewTargetDelay;
        public float HeroicNewTargetDelay;
        public float LegendaryNewTargetDelay;

        public float EasyBurstSeparation;
        public float NormalBurstSeparation;
        public float HeroicBurstSeparation;
        public float LegendaryBurstSeparation;

        public float EasyTargetTracking;
        public float NormalTargetTracking;
        public float HeroicTargetTracking;
        public float LegendaryTargetTracking;

        public float EasyTargetLeading;
        public float NormalTargetLeading;
        public float HeroicTargetLeading;
        public float LegendaryTargetLeading;

        public float EasyOverchargeChance;
        public float NormalOverchargeChance;
        public float HeroicOverchargeChance;
        public float LegendaryOverchargeChance;

        public float EasySpecialFireDelay;
        public float NormalSpecialFireDelay;
        public float HeroicSpecialFireDelay;
        public float LegendarySpecialFireDelay;

        public float EasyGuidanceVsPlayer;
        public float NormalGuidanceVsPlayer;
        public float HeroicGuidanceVsPlayer;
        public float LegendaryGuidanceVsPlayer;

        public float EasyMeleeDelayBase;
        public float NormalMeleeDelayBase;
        public float HeroicMeleeDelayBase;
        public float LegendaryMeleeDelayBase;

        public float EasyMeleeDelayScale;
        public float NormalMeleeDelayScale;
        public float HeroicMeleeDelayScale;
        public float LegendaryMeleeDelayScale;

        byte[] Padding2 = new byte[16];

        public float EasyGrenadeChanceScale;
        public float NormalGrenadeChanceScale;
        public float HeroicGrenadeChanceScale;
        public float LegendaryGrenadeChanceScale;

        public float EasyGrenadeTimerScale;
        public float NormalGrenadeTimerScale;
        public float HeroicGrenadeTimerScale;
        public float LegendaryGrenadeTimerScale;

        byte[] Padding3 = new byte[48];

        public float EasyMajorUpgrade_Normal;
        public float NormalMajorUpgrade_Normal;
        public float HeroicMajorUpgrade_Normal;
        public float LegendaryMajorUpgrade_Normal;

        public float EasyMajorUpgrade_Few;
        public float NormalMajorUpgrade_Few;
        public float HeroicMajorUpgrade_Few;
        public float LegendaryMajorUpgrade_Few;

        public float EasyMajorUpgrade_Many;
        public float NormalMajorUpgrade_Many;
        public float HeroicMajorUpgrade_Many;
        public float LegendaryMajorUpgrade_Many;

        public float EasyPlayerVehicleRamChance;
        public float NormalPlayerVehicleRamChance;
        public float HeroicPlayerVehicleRamChance;
        public float LegendaryPlayerVehicleRamChance;

        byte[] Padding4 = new byte[132];

        public void SetAll(int difficulty)
        {
            FieldInfo[] feilds = typeof(AIDifficulty).GetFields(BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < feilds.Length; i+=4)
            {
                float value = (float)feilds[i + difficulty].GetValue(this);
                feilds[i + 0].SetValue(this, value);
                feilds[i + 1].SetValue(this, value);
                feilds[i + 2].SetValue(this, value);
                feilds[i + 3].SetValue(this, value);
            }
        }

        public void ReadFrom(BaseStream stream)
        {
            EasyEnemyDamage = stream.ReadFloat();
            NormalEnemyDamage = stream.ReadFloat();
            HeroicEnemyDamage = stream.ReadFloat();
            LegendaryEnemyDamage = stream.ReadFloat();

            EasyEnemyVitality = stream.ReadFloat();
            NormalEnemyVitality = stream.ReadFloat();
            HeroicEnemyVitality = stream.ReadFloat();
            LegendaryEnemyVitality = stream.ReadFloat();

            EasyEnemySheild = stream.ReadFloat();
            NormalEnemySheild = stream.ReadFloat();
            HeroicEnemySheild = stream.ReadFloat();
            LegendaryEnemySheild = stream.ReadFloat();

            EasyEnemyRecharge = stream.ReadFloat();
            NormalEnemyRecharge = stream.ReadFloat();
            HeroicEnemyRecharge = stream.ReadFloat();
            LegendaryEnemyRecharge = stream.ReadFloat();

            EasyFriendDamage = stream.ReadFloat();
            NormalFriendDamage = stream.ReadFloat();
            HeroicFriendDamage = stream.ReadFloat();
            LegendaryFriendDamage = stream.ReadFloat();

            EasyFriendVitality = stream.ReadFloat();
            NormalFriendVitality = stream.ReadFloat();
            HeroicFriendVitality = stream.ReadFloat();
            LegendaryFriendVitality = stream.ReadFloat();

            EasyFriendSheild = stream.ReadFloat();
            NormalFriendSheild = stream.ReadFloat();
            HeroicFriendSheild = stream.ReadFloat();
            LegendaryFriendSheild = stream.ReadFloat();

            EasyFriendRecharge = stream.ReadFloat();
            NormalFriendRecharge = stream.ReadFloat();
            HeroicFriendRecharge = stream.ReadFloat();
            LegendaryFriendRecharge = stream.ReadFloat();

            EasyInfectionForms = stream.ReadFloat();
            NormalInfectionForms = stream.ReadFloat();
            HeroicInfectionForms = stream.ReadFloat();
            LegendaryInfectionForms = stream.ReadFloat();

            Padding = stream.ReadBytes(Padding.Length);
            EasyRateOfFire = stream.ReadFloat();
            NormalRateOfFire = stream.ReadFloat();
            HeroicRateOfFire = stream.ReadFloat();
            LegendaryRateOfFire = stream.ReadFloat();

            EasyProjectileError = stream.ReadFloat();
            NormalProjectileError = stream.ReadFloat();
            HeroicProjectileError = stream.ReadFloat();
            LegendaryProjectileError = stream.ReadFloat();

            EasyBurstError = stream.ReadFloat();
            NormalBurstError = stream.ReadFloat();
            HeroicBurstError = stream.ReadFloat();
            LegendaryBurstError = stream.ReadFloat();

            EasyNewTargetDelay = stream.ReadFloat();
            NormalNewTargetDelay = stream.ReadFloat();
            HeroicNewTargetDelay = stream.ReadFloat();
            LegendaryNewTargetDelay = stream.ReadFloat();

            EasyBurstSeparation = stream.ReadFloat();
            NormalBurstSeparation = stream.ReadFloat();
            HeroicBurstSeparation = stream.ReadFloat();
            LegendaryBurstSeparation = stream.ReadFloat();

            EasyTargetTracking = stream.ReadFloat();
            NormalTargetTracking = stream.ReadFloat();
            HeroicTargetTracking = stream.ReadFloat();
            LegendaryTargetTracking = stream.ReadFloat();

            EasyTargetLeading = stream.ReadFloat();
            NormalTargetLeading = stream.ReadFloat();
            HeroicTargetLeading = stream.ReadFloat();
            LegendaryTargetLeading = stream.ReadFloat();

            EasyOverchargeChance = stream.ReadFloat();
            NormalOverchargeChance = stream.ReadFloat();
            HeroicOverchargeChance = stream.ReadFloat();
            LegendaryOverchargeChance = stream.ReadFloat();

            EasySpecialFireDelay = stream.ReadFloat();
            NormalSpecialFireDelay = stream.ReadFloat();
            HeroicSpecialFireDelay = stream.ReadFloat();
            LegendarySpecialFireDelay = stream.ReadFloat();

            EasyGuidanceVsPlayer = stream.ReadFloat();
            NormalGuidanceVsPlayer = stream.ReadFloat();
            HeroicGuidanceVsPlayer = stream.ReadFloat();
            LegendaryGuidanceVsPlayer = stream.ReadFloat();

            EasyMeleeDelayBase = stream.ReadFloat();
            NormalMeleeDelayBase = stream.ReadFloat();
            HeroicMeleeDelayBase = stream.ReadFloat();
            LegendaryMeleeDelayBase = stream.ReadFloat();

            EasyMeleeDelayScale = stream.ReadFloat();
            NormalMeleeDelayScale = stream.ReadFloat();
            HeroicMeleeDelayScale = stream.ReadFloat();
            LegendaryMeleeDelayScale = stream.ReadFloat();

            Padding2 = stream.ReadBytes(Padding2.Length);

            EasyGrenadeChanceScale = stream.ReadFloat();
            NormalGrenadeChanceScale = stream.ReadFloat();
            HeroicGrenadeChanceScale = stream.ReadFloat();
            LegendaryGrenadeChanceScale = stream.ReadFloat();

            EasyGrenadeTimerScale = stream.ReadFloat();
            NormalGrenadeTimerScale = stream.ReadFloat();
            HeroicGrenadeTimerScale = stream.ReadFloat();
            LegendaryGrenadeTimerScale = stream.ReadFloat();

            Padding3 = stream.ReadBytes(Padding3.Length);

            EasyMajorUpgrade_Normal = stream.ReadFloat();
            NormalMajorUpgrade_Normal = stream.ReadFloat();
            HeroicMajorUpgrade_Normal = stream.ReadFloat();
            LegendaryMajorUpgrade_Normal = stream.ReadFloat();

            EasyMajorUpgrade_Few = stream.ReadFloat();
            NormalMajorUpgrade_Few = stream.ReadFloat();
            HeroicMajorUpgrade_Few = stream.ReadFloat();
            LegendaryMajorUpgrade_Few = stream.ReadFloat();

            EasyMajorUpgrade_Many = stream.ReadFloat();
            NormalMajorUpgrade_Many = stream.ReadFloat();
            HeroicMajorUpgrade_Many = stream.ReadFloat();
            LegendaryMajorUpgrade_Many = stream.ReadFloat();

            EasyPlayerVehicleRamChance = stream.ReadFloat();
            NormalPlayerVehicleRamChance = stream.ReadFloat();
            HeroicPlayerVehicleRamChance = stream.ReadFloat();
            LegendaryPlayerVehicleRamChance = stream.ReadFloat();
        }

        public void WriteTo(BaseStream stream)
        {
            stream.Write(EasyEnemyDamage);
            stream.Write(NormalEnemyDamage);
            stream.Write(HeroicEnemyDamage);
            stream.Write(LegendaryEnemyDamage);

            stream.Write(EasyEnemyVitality);
            stream.Write(NormalEnemyVitality);
            stream.Write(HeroicEnemyVitality);
            stream.Write(LegendaryEnemyVitality);

            stream.Write(EasyEnemySheild);
            stream.Write(NormalEnemySheild);
            stream.Write(HeroicEnemySheild);
            stream.Write(LegendaryEnemySheild);

            stream.Write(EasyEnemyRecharge);
            stream.Write(NormalEnemyRecharge);
            stream.Write(HeroicEnemyRecharge);
            stream.Write(LegendaryEnemyRecharge);

            stream.Write(EasyFriendDamage);
            stream.Write(NormalFriendDamage);
            stream.Write(HeroicFriendDamage);
            stream.Write(LegendaryFriendDamage);

            stream.Write(EasyFriendVitality);
            stream.Write(NormalFriendVitality);
            stream.Write(HeroicFriendVitality);
            stream.Write(LegendaryFriendVitality);

            stream.Write(EasyFriendSheild);
            stream.Write(NormalFriendSheild);
            stream.Write(HeroicFriendSheild);
            stream.Write(LegendaryFriendSheild);

            stream.Write(EasyFriendRecharge);
            stream.Write(NormalFriendRecharge);
            stream.Write(HeroicFriendRecharge);
            stream.Write(LegendaryFriendRecharge);

            stream.Write(EasyInfectionForms);
            stream.Write(NormalInfectionForms);
            stream.Write(HeroicInfectionForms);
            stream.Write(LegendaryInfectionForms);

            stream.Write(Padding);

            stream.Write(EasyRateOfFire);
            stream.Write(NormalRateOfFire);
            stream.Write(HeroicRateOfFire);
            stream.Write(LegendaryRateOfFire);

            stream.Write(EasyProjectileError);
            stream.Write(NormalProjectileError);
            stream.Write(HeroicProjectileError);
            stream.Write(LegendaryProjectileError);

            stream.Write(EasyBurstError);
            stream.Write(NormalBurstError);
            stream.Write(HeroicBurstError);
            stream.Write(LegendaryBurstError);

            stream.Write(EasyNewTargetDelay);
            stream.Write(NormalNewTargetDelay);
            stream.Write(HeroicNewTargetDelay);
            stream.Write(LegendaryNewTargetDelay);

            stream.Write(EasyBurstSeparation);
            stream.Write(NormalBurstSeparation);
            stream.Write(HeroicBurstSeparation);
            stream.Write(LegendaryBurstSeparation);

            stream.Write(EasyTargetTracking);
            stream.Write(NormalTargetTracking);
            stream.Write(HeroicTargetTracking);
            stream.Write(LegendaryTargetTracking);

            stream.Write(EasyTargetLeading);
            stream.Write(NormalTargetLeading);
            stream.Write(HeroicTargetLeading);
            stream.Write(LegendaryTargetLeading);

            stream.Write(EasyOverchargeChance);
            stream.Write(NormalOverchargeChance);
            stream.Write(HeroicOverchargeChance);
            stream.Write(LegendaryOverchargeChance);

            stream.Write(EasySpecialFireDelay);
            stream.Write(NormalSpecialFireDelay);
            stream.Write(HeroicSpecialFireDelay);
            stream.Write(LegendarySpecialFireDelay);

            stream.Write(EasyGuidanceVsPlayer);
            stream.Write(NormalGuidanceVsPlayer);
            stream.Write(HeroicGuidanceVsPlayer);
            stream.Write(LegendaryGuidanceVsPlayer);

            stream.Write(EasyMeleeDelayBase);
            stream.Write(NormalMeleeDelayBase);
            stream.Write(HeroicMeleeDelayBase);
            stream.Write(LegendaryMeleeDelayBase);

            stream.Write(EasyMeleeDelayScale);
            stream.Write(NormalMeleeDelayScale);
            stream.Write(HeroicMeleeDelayScale);
            stream.Write(LegendaryMeleeDelayScale);

            stream.Write(Padding2);

            stream.Write(EasyGrenadeChanceScale);
            stream.Write(NormalGrenadeChanceScale);
            stream.Write(HeroicGrenadeChanceScale);
            stream.Write(LegendaryGrenadeChanceScale);

            stream.Write(EasyGrenadeTimerScale);
            stream.Write(NormalGrenadeTimerScale);
            stream.Write(HeroicGrenadeTimerScale);
            stream.Write(LegendaryGrenadeTimerScale);

            stream.Write(Padding3);

            stream.Write(EasyMajorUpgrade_Normal);
            stream.Write(NormalMajorUpgrade_Normal);
            stream.Write(HeroicMajorUpgrade_Normal);
            stream.Write(LegendaryMajorUpgrade_Normal);

            stream.Write(EasyMajorUpgrade_Few);
            stream.Write(NormalMajorUpgrade_Few);
            stream.Write(HeroicMajorUpgrade_Few);
            stream.Write(LegendaryMajorUpgrade_Few);

            stream.Write(EasyMajorUpgrade_Many);
            stream.Write(NormalMajorUpgrade_Many);
            stream.Write(HeroicMajorUpgrade_Many);
            stream.Write(LegendaryMajorUpgrade_Many);

            stream.Write(EasyPlayerVehicleRamChance);
            stream.Write(NormalPlayerVehicleRamChance);
            stream.Write(HeroicPlayerVehicleRamChance);
            stream.Write(LegendaryPlayerVehicleRamChance);
        }
    }
}